#!/usr/local/bin/python
#-*- encoding:utf-8 -*- 
import string 
from whoosh.index import create_in  
from whoosh.fields import *  
import jieba.analyse
from whoosh.index import open_dir
from whoosh.scoring import *
from whoosh.matching import *
from whoosh.qparser import QueryParser
import utils


'''This script transform the test set to vectors, for matching model to score'''

config = utils.get_config();
analyzer = jieba.analyse.ChineseAnalyzer();

dictMap = {};
d = open(config.get('rmls', 'dictionary'), 'r');
index = 0;
for line in d:
    dictMap[index] = line.strip('\n').split('\t')[0];
    index += 1;
d.close();
MAX = len(dictMap);
print MAX;

if __name__ == '__main__':
	indexFile = open(sys.argv[1], 'r');
	wordFile = open(sys.argv[2], 'w');
	for line in indexFile:
		li = line.strip().split('\t');
		first = int(li[0]);
		second = int(li[1]);
		third = li[2];
		wordFile.write('%s\t%s\t%s\n' % (dictMap[first], dictMap[second], third));
	indexFile.close();
	wordFile.close();

